package com.tjx.controller;


import com.tjx.common.Result;
import com.tjx.entity.Performance;
import com.tjx.mapper.PerformanceMapper;
import com.tjx.service.IPerformanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 演出表 前端控制器
 * </p>
 *
 * @author tjx
 * @since 2025-10-29
 */
@RestController
@RequestMapping("/performance")
public class PerformanceController {

    @Autowired
    private IPerformanceService performanceService;

    /**
     * 查询所有演出
     */
    @PostMapping("/performanceQueryAll")
    public Result<List<Performance>> performanceQueryAll() {
        List<Performance> performanceList = performanceService.performanceQueryAll();
        if (performanceList == null) {
            return Result.fail();
        }
        return Result.ok(performanceList);
    }

     /**
     * 新增演出
     */
    @PostMapping("/performanceAdd")
    public Result<Performance> performanceAdd(@RequestBody Performance performance) {
        Integer row = performanceService.performanceAdd(performance);
        if (row > 0) {
            return Result.ok();
        }
        return Result.fail();
    }

     /**
     * 更新演出
     */
    @PostMapping("/performanceUpdate")
    public Result<Performance> performanceUpdate(@RequestBody Performance performance) {
        Integer row = performanceService.performanceUpdate(performance);
        if (row > 0) {
            return Result.ok();
        }
        return Result.fail();
    }

    /**
     * 删除演出
     */
    @PostMapping("/performanceDelete")
    public Result<Performance> performanceDelete(@RequestBody Performance performance) {
        Integer row = performanceService.performanceDelete(performance);
        if (row > 0) {
            return Result.ok();
        }
        return Result.fail();
    }
}
